// Find all the permutations of a string.
// By Ben 25/10/2018

#include <iostream>
#include <algorithm>

using namespace std;

using std::cout;
using std::endl;

int Length(char *s){
	int x = 0;

	while (*s){
		x++;
		s++;
	}
	return x;
}

int main()
{
	char s0[20];
	std::cout << "Enter a string to find all permutations: ";
	std::cin >> s0;

	int len = Length(s0);
	//sort the string
	sort(s0, s0 + len);

	do{
		//Output all the permutation for s0
		std::cout << s0 << endl;
	} while (next_permutation(s0, s0 + len));

	system("pause");
	return 0;
}
